#pragma once
#include "DXAMLCommon.h"

#include "XamlScannerNode.h"

class XamlParserState
{
public: 
	XamlParserState();
	~XamlParserState();
	typedef HRESULT(* PFNAction)();

	enum ParseState
	{
		psError = 0x0,
		psStart = 0x1,
		psPrefix = 0x2,
		psStartTag = 0x3,
		psDirective = 0x4,
		psAttribute = 0x5,
		psText = 0x6,
		psEndTag = 0x7,
		psNumberOfParseStates = 0x8
	};

	struct ParserStateTransition
	{
		PFNAction m_ActionFunction;
		PFNAction m_PostTransitionActionFunction;
		enum ParseState m_NextState;
	};

	HRESULT Transition(enum XamlScannerNode::ScannerNodeType inputNodeType,  PFNAction* outpfnAction,  PFNAction* outpfnpostTransitionAction) ;
	enum XamlParserState::ParseState CurrentState();
	enum XamlParserState::ParseState PreviousState();
private: 
	void AddTransition(enum ParseState currentState, enum XamlScannerNode::ScannerNodeType inputNodeType, enum ParseState nextState, PFNAction parseAction,  PFNAction postTransitionAction);
	void PopulateTransitionTable();
	void ZeroTransitionTable();
	enum ParseState m_CurrentState;
	enum ParseState m_PreviousState;
	struct ParserStateTransition m_TransitionTable[8];

};
